<?PHP

function metarefresh($url = "", $title = "", $body = "")
{
    if(empty($url))
        $url = @$_SESSION['requested_url'];
    if(empty($url))
        $url = URL_DEFAULT ;

    $meta = new metaheader("/dpstyle.css", $url);
    $meta->setTitle($title);
    $meta->setBody($body);
    echo $meta->text();
}

class metaheader
{
    private $_delay = 0;
    private $_url;
    private $_CSS_path;
    private $_title;
    private $_body;

    function metaheader($CSS_path, $url)
    {
        $this->_CSS_path = $CSS_path;
        $this->_url = $url;
    }

    function setTitle($title)
    {
        $this->_title = $title;
    }

    function setBody($text)
    {
        $this->_body = $text;
    }

    function text($delay = -1)
    {
        if($delay >= 0) {
            $this->_delay = $delay;
        }
        return <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>$this->_title</title>
<meta http-equiv="refresh" content="$this->_delay;URL=$this->_url">
<meta http-equiv="Content-Type" content="text/html; charset='utf-8'" />
<link rel="stylesheet" href="$this->_CSS_path" type="text/css" />
</head>
<body>
$this->_body
</body>
</html>
EOT;
    }
}
?>
